<!doctype html>
<html>
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
	<script src="http://img.mukewang.com/down/540812440001e40e00000000.js" type="text/javascript"></script>
	<title>DOM删除</title>
</head>
<body>

<button id="test1">empty操作</button>
<button id="test2">remove操作</button>


<div class="container">
  <div class="empty">empty</div>
  <div class="remove">remove</div>
  <div class="goodbye">Goodbye</div>
</div>

<script type="text/javascript">

function empty() {
	var elem,
		i = 0;
	for (;
		(elem = this[i]) != null; i++) {
		if (elem.nodeType === 1) {
			elem.textContent = "";
		}
	}
	return this;
}


function remove(selector, keepData /* Internal Use Only */ ) {
    var elem,i = 0;
    for (;
        (elem = this[i]) != null; i++) {
        if (elem.parentNode) {
            elem.parentNode.removeChild(elem);
        }
    }
    return this;
}

$('#test1').click(function() {
	var elem = document.querySelectorAll('.empty')
	empty.call(elem)
})

$('#test2').click(function() {
	var elem = document.querySelectorAll('.remove')
	remove.call(elem)
})




</script>

</body>
</html>

